<template>
  <div class="newsinfo-container">
    <h3 class="title"> {{newsinfo.title}} </h3>
    <p class="subtitle">
      <span>发表时间:{{ newsinfo.add_time | dateFormat }} </span>
      <span>点击:{{ newsinfo.click }}</span>
    </p>
    <hr>
    <div class="content" v-html="newsinfo.content"></div>
    <com :id = 'this.id'></com>
    
  </div>
</template>

<script>
import {Toast} from "mint-ui";
import comment from "../subcomponents/comment.vue";
export default {
  data(){
    return {
      id:this.$route.params.id,// 将url 地址中的参数传递过来
      newsinfo:{}// 新闻对象
    }
  },
  created(){
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      // 获取新闻详情
      this.$http.get("api/getnew/" + this.id).then(result => {
        if (result.body.status === 0) {
          this.newsinfo = result.body.message[0];
          console.log(this.newsinfo)
        } else {
          Toast("获取新闻失败！");
        }
      });
    }
  },
  components:{
    'com':comment
  }
}
</script>

<style lang="scss" scoped>
  .newsinfo-container {
    padding: 0 4px;
    h3{
      font-size: 16px;
      color:red;
      text-align: center;
    }
    .subtitle{
      font-size: 12px;
      display: flex;
      justify-content: space-between;
      color:#05a4ee;
    }
    .content{
       p {
        color:red;
        text-indent: 2em !important;
      }
    }
  }
</style>